package com.hdu.transmitableThreadLocal;


import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;


import static com.hdu.transmitableThreadLocal.TransmitableRunnable.wrap;

public class Main {
    public static void main(String[] args) {
        TransmitableThreadLocal<String> threadLocal = new TransmitableThreadLocal<>();
        threadLocal.set("1");
        ExecutorService executor = Executors.newFixedThreadPool(1);
        executor.execute(
                TransmitableRunnable.wrap(
                        () -> System.out.println("子线程打印 : " + threadLocal.get())
                )
        );
        threadLocal.set("2");
        executor.execute(
                TransmitableRunnable.wrap(
                        () -> System.out.println("子线程打印 : " + threadLocal.get())
                )
        );
        threadLocal.set("3");
        executor.execute(
                TransmitableRunnable.wrap(
                        () -> System.out.println("子线程打印 : " + threadLocal.get())
                )
        );
        //子线程打印 : 1
        //子线程打印 : 2
        //子线程打印 : 3
        executor.shutdown();
    }
}
